/*
 * KeyStoreEntryEditor.java
 *
 * Created on 05 May 2006, 09:33
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.tastefuljava.minica;

import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;


public class KeyStoreEntryEditor extends AbstractCellEditor 
        implements TableCellEditor {
    private JTextField editor = new JTextField();
    private KeyStoreEntry entry;

    public KeyStoreEntryEditor() {
    }

    public Object getCellEditorValue() {
        return entry == null ? null : entry.copy(editor.getText());
    }

    public Component getTableCellEditorComponent(JTable table, Object value, 
            boolean isSelected, int row, int column) {
        entry = (KeyStoreEntry)value;
        editor.setText(entry == null ? "" : entry.getAlias());
        return editor;
    }
}
